using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL
{

    /// <summary>
    /// The EnquiryTableManager class is responsible for managing BO.EnquiryTable objects in the system.
    /// </summary>
    [DataObjectAttribute()]
    public class EnquiryTableManager
    {

        #region "Public Methods"

        /// <summary>
        /// Gets a list with all EnquiryTable objects in the database.
        /// </summary>
        /// <returns>A list with all EnquiryTable from the database when the database contains any, or null otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public static EnquiryTableList GetList()
        {
            return EnquiryTableDB.GetList();
        }

        /// <summary>
        /// Gets a single EnquiryTable from the database without its data.
        /// </summary>
        /// <param name="enquiryKey">The EnquiryKey of the EnquiryTable in the database.</param>
        /// <returns>A EnquiryTable object when the EnquiryKey exists in the database, or <see langword="null"/> otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static EnquiryTable GetItem(int enquiryKey)
        {
            return GetItem(enquiryKey, false);
        }

        /// <summary>
        /// Gets a single EnquiryTable from the database.
        /// </summary>
        /// <param name="enquiryKey">The EnquiryKey of the EnquiryTable in the database.</param>
        /// <param name="getEnquiryTableRecords">Determines whether to load all associated EnquiryTable records as well.</param>
        /// <returns>
        /// A EnquiryTable object when the EnquiryKey exists in the database, or <see langword="null"/> otherwise.
        /// </returns>
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public static EnquiryTable GetItem(int enquiryKey, bool getEnquiryTableRecords)
        {
            EnquiryTable myEnquiryTable = EnquiryTableDB.GetItem(enquiryKey);
            return myEnquiryTable;
        }

        /// <summary>
        /// Saves a EnquiryTable in the database.
        /// </summary>
        /// <param name="myEnquiryTable">The EnquiryTable instance to save.</param>
        /// <returns>The new EnquiryKey if the EnquiryTable is new in the database or the existing EnquiryKey when an item was updated.</returns>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
        public static int Save(EnquiryTable myEnquiryTable)
        {
            using (TransactionScope myTransactionScope = new TransactionScope())
            {
                int enquiryTableEnquiryKey = EnquiryTableDB.Save(myEnquiryTable);

                //  Assign the EnquiryTable its new (or existing EnquiryKey).
                myEnquiryTable.EnquiryKey = enquiryTableEnquiryKey;

                myTransactionScope.Complete();

                return enquiryTableEnquiryKey;
            }
        }

        /// <summary>
        /// Deletes a EnquiryTable from the database.
        /// </summary>
        /// <param name="myEnquiryTable">The EnquiryTable instance to delete.</param>
        /// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public static bool Delete(int EnquiryKey)
        {
            return EnquiryTableDB.Delete(EnquiryKey);
        }

        #endregion

    }

}
